package cn.cocho.custom.yunCashierDf.common.controller;

import cn.cocho.common.web.app.JsonResultContants;
import cn.cocho.custom.yunCashierDf.agency.domain.AgencyInfo;
import cn.cocho.custom.yunCashierDf.agency.service.AgencyInfoService;
import cn.cocho.custom.yunCashierDf.common.domain.CodelistInfo;
import cn.cocho.custom.yunCashierDf.common.service.CommonService;
import cn.cocho.custom.yunCashierDf.merchant.domain.MerchantInfo;
import cn.cocho.custom.yunCashierDf.merchant.domain.MerchantTransactionInfo;
import cn.cocho.custom.yunCashierDf.merchant.service.MerchantInfoService;
import cn.cocho.custom.yunCashierDf.merchant.service.MerchantTransactionInfoService;
import cn.cocho.custom.yunCashierDf.utils.JsonResult;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by WQJ on 2017/5/22.
 */
@Controller
public class CommonController {

    @Autowired
    private CommonService commonService;

    @Autowired
    private AgencyInfoService agencyInfoService;

    @Autowired
    private MerchantInfoService merchantInfoService;

    @Autowired
    private MerchantTransactionInfoService merchantTransactionInfoService;

    @ResponseBody
    @RequestMapping(value = "/members/common/getLevelInfo")
    public JsonResult getLevelInfo() {
        List<CodelistInfo> list = commonService.getCodeListInfo("RY_JB_DM");
        JsonResult result = new JsonResult(JsonResultContants.SUCCESS, "获取成功", list);
        return result;
    }

    @ResponseBody
    @RequestMapping(value = "/members/common/getXwlbInfo")
    public JsonResult getXwlbInfo() {
        List<CodelistInfo> list = commonService.getCodeListInfo("RY_XWLB_DM");
        JsonResult result = new JsonResult(JsonResultContants.SUCCESS, "获取成功", list);
        return result;
    }

    @ResponseBody
    @RequestMapping(value = "/members/common/getAgencyInfo")
    public JsonResult getAgencyInfo() {
        List<AgencyInfo> list = agencyInfoService.getAgencyInfo();
        JsonResult result = new JsonResult(JsonResultContants.SUCCESS, "获取成功", list);
        return result;
    }

    @ResponseBody
    @RequestMapping(value = "/members/common/getMerchantInfo")
    public JsonResult getMerchantInfo() {
        List<MerchantInfo> list = merchantInfoService.getMerchantInfo();
        JsonResult result = new JsonResult(JsonResultContants.SUCCESS, "获取成功", list);
        return result;
    }
}
